#导入蓝图
from flask import Blueprint,request,jsonify

#转格式
import json

#导入数据库类
from db import Db
db=Db()
#实例化蓝图
user = Blueprint('user',__name__)


#用户登录
@user.route('/login/',methods=['GET'])
async def logins():
    #获取数据
    mobile = request.args.get('mobile')
    password = request.args.get('password')
    #和数据库数据进行对比
    sql = "select * from user where mobile = '%s'" % mobile
    user = db.get_one(sql)
    print(user)
    if user:
        if user['password']  == password:
            return {'code':200,'userid':user['id']}
        else:
            return {'code':403,'msg':'密码或账号错误'}
    else:
        return {'code': 20020, 'msg': '没有该用户'}



